package com.wxapp.common.constant.enums;

import com.wxapp.common.constant.base.IBaseEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author lgl
 * @Description 用户类型
 * @Datetime 2022/6/1 11:04
 * @Modified By
 */
@Getter
public enum ClientTypeEnum implements IBaseEnum<String> {
    WECHAT("weChat","微信"),
    WEB("web", "web"),
    INSIDER("insider", "内部");

    private final String value;
    private final String desc;

    ClientTypeEnum(String value, String desc) {
        this.desc = desc;
        this.value = value;
    }
    /**
     * 根据code查找
     * @param code 枚举code
     * @return 枚举对象
     */
    public static List<ClientTypeEnum> findEnumByVales(String ... code) {
        if (code.length == 0){
            return null;
        }
        List<String> codes=Arrays.asList(code);
        List<ClientTypeEnum> result=new ArrayList<>();
        for (ClientTypeEnum statusEnum : ClientTypeEnum.values()) {
            if (codes.contains(statusEnum.getValue())) {
                //如果需要直接返回name则更改返回类型为String,return statusEnum.name;
                result.add(statusEnum);
            }
        }
       return result.size()==0?null:result;
    }
}
